erDiagram
    USERS {
        int id PK
        string username UK
        string password_hash
        string role
        string company_name
        string legal_person
        string phone
        datetime created_at
    }
    
    TENDERS {
        int id PK
        string tender_code UK
        string drug_name
        string manufacturer
        string package_req
        int total_quantity
        datetime deadline
        decimal deposit_amount
        int created_by FK
        datetime created_at
        datetime updated_at
    }
    
    BIDS {
        int id PK
        datetime bid_date
        int bidder_id FK
        string legal_person
        string phone
        int tender_id FK
        string product_batch
        datetime production_date
        datetime expiry_date
        decimal total_amount
        datetime deposit_paid_date
        datetime created_at
    }
    
    MESSAGES {
        int id PK
        int author_id FK
        int tender_id FK "可空"
        string content
        datetime created_at
    }
    
    USERS ||--o{ TENDERS : "creates"
    USERS ||--o{ BIDS : "submits"
    USERS ||--o{ MESSAGES : "posts"
    TENDERS ||--o{ BIDS : "receives"
    TENDERS ||--o{ MESSAGES : "has"

